<template>
    <div>
        <h1 class="title">订单列表</h1>  
        <ul class="orderlist safe">
            <li v-for="item in list" :key="item.id">
                <div class="top">
                    <p>订单编号:{{item.order_number}}</p>
                    <span>{{item.status}}</span>
                </div>
                
                <div class="con">
                    <p>商品id:{{item.goods_id}}</p>
                    <span>{{item.realname}}</span>
                    <span>所用积分:{{item.price}}</span>
                    <p class="time">{{item.create_time}}</p>
                </div>
                <button @click="goOrderDetail(item.id)">查看订单详情</button>
            </li>    
        </ul>      
    </div>
</template>
<script>
import api from "../../libs/js/integralAjax"
export default {
    data(){
        return{
            list:[],
            token:''
        }
    },
    created(){
        this.token = this.$store.state.options.user.token
        this.getList()
    },
    methods:{
        //去订单详情
        goOrderDetail(e){
            this.$router.push({
                name:'ShopAwaitIntegralOrder',
                params:{
                    id:e,
                    token:this.token
                }

            })
        },
        //获取订单列表
        getList:async function(){
            var url='/api/admin/integral/order/GetList'
            var param={
                page:0,
                list_rows:10,
                token:this.token
            }
            this.$util.postRequestInterface(url, param, (res) => {
                console.log(res.data.data)
                let list = res.data.data
                list.forEach(function(item,index,a){
                    if(item.status==2){
                        item.status = '已发放'
                    }
                    else if(item.status==3){
                        item.status = '已取消'
                    }
                    else if(item.status==21){
                        item.status = '待主管确认'
                    }
                    else if(item.status==22){
                        item.status = '待暂存点确认'
                    }
                    else if(item.status==23){
                        item.status = '待业务员确认'
                    }
                    else if(item.status==24){
                        item.status = '待门店确认'
                    }
                
                })
                this.list = list
            })
        }
    }
}
</script>
<style lang="scss" scoped>
    .title{
        text-align: center;
    }
    .safe{
        width: 100rem;
        height: 60rem;
        margin: 0 auto;
        overflow: auto;

        li{ 
            width: 98rem;
            height: 20rem;
            box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3);
            margin: 1rem 0;
            border-radius: 5px;
            span{
                margin: 0 0.5rem;
            }
        }
    }
    .top{
        width: 95%;
        height: 4rem;
        line-height: 4rem;
        margin: 0 auto;
        border-bottom: 1px solid rgb(180, 180, 180);
        p{
            color:rgb(180, 180, 180);
            float: left;
        }
        span{
            float: right;
            color: rgb(0,205,0)
        }
    }
    .con{
        width: 95%;
        height: 8rem;
        line-height: 4rem;
        margin: 0 auto;
        border-bottom: 1px solid rgb(180, 180, 180);
        p{
            font-size: 20px;
        }
        span{
            font-size: 14px;
        }
        .time{
            float: right;
            font-size: 16px;
        }
    }
    button{
        float: right;
        color: white;
        background: rgb(0,205,0);
        border: none;
        line-height: 30px;
        border-radius: 15px;
        margin: 2rem 2rem 0 0;
    }
</style>